 <!-- main content start-->
      <section id="main-content">
          <section class="wrapper">
          	<h3><i class="fa fa-angle-right"></i>  分类列表</h3>
				<div class="row">
				
	                  <div class="col-md-12">
	                  	  <div class="content-panel">
	                  	  	  <hr>
		                      <table class="table">
		                          <thead>
		                          <tr>
		                              <th width="70">ID</th>
		                              <th width="550" class="col-md-2">名称</th>
		                              <th>pid</th>
                                  <th>操作</th>
		                          </tr>
		                          </thead>
		                          <tbody>
                              <?php foreach($cate as $v){
                              ?>
		                          <tr level="1" pid='<?php echo $v['pid']?>'>
		                              <td><?php echo $v['id']?></td>
		                              <td filed="title" class="db_edit">
										<button id="<?php echo $v['id']?>" class="btn btn-info" style="background: #ff865c;">+</button>
		                              <?php echo $v['name']?></td>
		                              <td class="db_edit"><?php echo $v['pid']?></td>
                                  <td class="col-md-2">
                                  <a href="index.php?c=news&a=edit&admin=1&id=<?php echo $v['id']?>" class="btn btn-info">
                                    <i class="fa fa-pencil-square-o"></i>编辑</a>
                                  </a>
                                  <a href="index.php?c=news&a=add&admin=1&id=<?php echo $v['id']?>" class="btn btn-danger" onclick="return confirm('真的要删除吗？')">
                                    <i class="fa fa-trash-o"></i>删除</a>
                                  </a>
                                  </td>
		                          </tr>
                              <?php }?>
		                          </tbody>
		                      </table>
	                  	  </div><! --/content-panel -->

	                  </div><!-- /col-md-12 -->
                  
				</div><!-- row -->



		</section><! --/wrapper -->
      </section><!-- /MAIN CONTENT -->

      <!--main content end-->

      <script src="resource/admin/assets/js/jquery-2.1.4.min.js"></script>

      <script type="text/javascript">

			$(function(){
				var i=1;
				$("tbody").on('click','.btn',function(){
					// var left = 1*40;
					// i++;
					var obj = $(this);
					//当前操作的button的tr对象
					var tr_obj = $(this).parent().parent();
					var pid = tr_obj.attr('pid');//获取当前行的pid属性值
					//获取当前对象集合里面对应传递的对象的下标值
					var index =$('tr[pid='+pid+']').index(tr_obj);
					//获取当前同级的tr长度
					var len = $('tr[pid='+pid+']').length-1;
					var id = $(this).attr('id');//获取自定义属性的id值
					if('+'==$(this).text()){
						//获取自定义等级
						var level = parseInt(tr_obj.attr("level"));
						    left = level*40;

						    level++;
						$(this).text('-')
						$.ajax({
							type:'get',
							url:'index.php?c=cate&a=list&admin=1&id='+id,
							dataType:'json',
							success:function(json){
								      var html='';
								      for(i in json){
								      html+='<tr level="'+level+'" pid='+id+'>';
		                              html+='<td>'+json[i].id+'</td>';
		                              html+='<td filed="title" class="db_edit" style="padding-left:'+left+'px">';
										html+='<button id="'+json[i].id+'" class="btn btn-info" style="background: #ff865c;">+</button>&nbsp;&nbsp'+json[i].name+'</td>';
		                              html+='<td class="db_edit">'+json[i].pid+'</td>';
                                  html+='<td class="col-md-2">';
                                  html+='<a href="index.php?c=news&a=edit&admin=1&id='+json[i].id+'" class="btn btn-info">';
                                    html+='<i class="fa fa-pencil-square-o"></i>编辑</a>';
                                  html+='<a href="index.php?c=news&a=add&admin=1&id='+json[i].id+'" class="btn btn-danger" onclick="return confirm()">';
                                    html+='<i class="fa fa-trash-o"></i>删除</a>';
                                  html+='</td>';
		                          html+='</tr>';
		                          }

								if(len==index){

									html+='<tr pid="'+pid+'" style="display:none"></tr>';
								}

		                          //给父级的后面添加内容
								tr_obj.after(html);

							}
						})
					}else{

						$(this).text('+');

						var pid = tr_obj.attr('pid');

					    $(tr_obj).nextUntil('tr[pid='+pid+']').remove();
					}

				})
			})

      </script>